﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StreamDemo
{
    internal class Program
    {
        static void Main(string[] args)
        {
            StreamReaderDemo();
            Console.ReadKey();
        }

        static void StreamReaderDemo()
        {
            string filename = @"D:\test\test.txt";
            string tofilename = @"D:\test\testbak.txt";

            using (StreamReader reader = new StreamReader(filename, Encoding.UTF8))
            using (StreamWriter writer = new StreamWriter(tofilename, true, Encoding.UTF8))
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    Console.WriteLine(line);
                    writer.WriteLine(line);
                }
            }

        }
    }
}
